// 多个权限显示节点
export const permissions = {
	install(Vue) {
		Vue.directive('permissions', {
			bind(el, binding, vnode) {
				const permissions_ = vnode.context.$store.state.permissions;
				const value = binding.value;
				let flag = true;
				for (const v of value) {
					if (!permissions_.includes(v)) {
						flag = false;
					}
				}
				if (!flag) {
					if (!el.parentNode) {
						el.style.display = 'none';
					} else {
						el.parentNode.removeChild(el);
					}
				}
			}
		})
	}
}

// 单个权限显示节点
export const permission = {
	install(Vue) {
		Vue.directive('permission', {
			bind(el, binding, vnode) {
				const permissions_ = vnode.context.$store.state.permissions;
				const value = binding.value;
				let flag = false;
				for (var i = 0; i < permissions_.length; i++) {
					if (value === permissions_[i]) {
						flag = true;
						break;
					}
				}
				if (!flag) {
					if (!el.parentNode) {
						el.style.display = 'none';
					} else {
						el.parentNode.removeChild(el);
					}
				}
			}
		})
	}
}
